package com.xcf.leetcode;

/**
 * Palindrome <br>
 *
 * @author xiaocf <br>
 * @version 1.0 <br>
 * @date 2020/6/22 20:52 <br>
 */
public class Palindrome {

    public boolean isPalindrome(int x) {
        if (x < 0) {
            return false;
        }
        if (x < 10) {
            return true;
        }
        int resource = x;
        int revert = 0;
        while (x != 0) {
            revert = revert * 10 + x % 10;
            x = x / 10;
        }
        return revert == resource;
    }

    public static void main(String[] args) {
        Palindrome palindrome = new Palindrome( );
        boolean isFlag = palindrome.isPalindrome(121);
        System.out.println(isFlag);
    }
}
